package com.ruoyi.web.controller.common;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.SysStorehouse;
import com.ruoyi.web.service.ISysStorehouseService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * storehouseController
 *
 * @author ruoyi
 * @date 2022-04-29
 */
@RestController
@RequestMapping("/web/storehouse")
public class SysStorehouseController extends BaseController
{
    @Autowired
    private ISysStorehouseService sysStorehouseService;

    /**
     * 查询storehouse列表
     */
    @PreAuthorize("@ss.hasPermi('web:storehouse:list')")
    @GetMapping("/list")
    public AjaxResult list(SysStorehouse sysStorehouse)
    {
        List<SysStorehouse> list = sysStorehouseService.selectSysStorehouseList(sysStorehouse);
        return AjaxResult.success(list);
    }

    /**
     * 导出storehouse列表
     */
    @PreAuthorize("@ss.hasPermi('web:storehouse:export')")
    @Log(title = "storehouse", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysStorehouse sysStorehouse)
    {
        List<SysStorehouse> list = sysStorehouseService.selectSysStorehouseList(sysStorehouse);
        ExcelUtil<SysStorehouse> util = new ExcelUtil<SysStorehouse>(SysStorehouse.class);
        return util.exportExcel(list, "storehouse");
    }

    /**
     * 获取storehouse详细信息
     */
    @PreAuthorize("@ss.hasPermi('web:storehouse:query')")
    @GetMapping(value = "/{recNo}")
    public AjaxResult getInfo(@PathVariable("recNo") String recNo)
    {
        return AjaxResult.success(sysStorehouseService.selectSysStorehouseById(recNo));
    }

    /**
     * 新增storehouse
     */
    @PreAuthorize("@ss.hasPermi('web:storehouse:add')")
    @Log(title = "storehouse", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysStorehouse sysStorehouse)
    {
        return toAjax(sysStorehouseService.insertSysStorehouse(sysStorehouse));
    }

    /**
     * 修改storehouse
     */
    @PreAuthorize("@ss.hasPermi('web:storehouse:edit')")
    @Log(title = "storehouse", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysStorehouse sysStorehouse)
    {
        return toAjax(sysStorehouseService.updateSysStorehouse(sysStorehouse));
    }

    /**
     * 删除storehouse
     */
    @PreAuthorize("@ss.hasPermi('web:storehouse:remove')")
    @Log(title = "storehouse", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recNos}")
    public AjaxResult remove(@PathVariable String[] recNos)
    {
        return toAjax(sysStorehouseService.deleteSysStorehouseByIds(recNos));
    }
}
